package com.rubiksillusions;

public class Facelet {
	private int number;
	private final Color color;
	private final Cubelet cubelet;
	private int semiAxis;
	
	public Facelet(Cubelet cubelet, int number, int semiAxis, Color color) {
		this.number = number;
		this.color = color;
		this.cubelet = cubelet;
		this.semiAxis = semiAxis;
	}
	
	public int getNumber() {
		return number;
	}
	
	public Color getColor() {
		return color;
	}
	
	public Cubelet getCubelet() {
		return cubelet;
	}
	
	public int getSemiAxis() {
		return semiAxis;
	}
	
	/*
	 * Ruoto la faccia di 90 gradi in senso orario rispetto all'asse di rotazione.
	 * Cambiano semiAxis e number.
	 */
	public void rotation(int axis) {
		switch (axis) {
			case Axis.X:
				switch (getSemiAxis()) {
					case SemiAxis.XP:
						semiAxis = SemiAxis.XP;
						break;
					case SemiAxis.XN:
						semiAxis = SemiAxis.XN;
						break;
					case SemiAxis.YP:
						semiAxis = SemiAxis.ZN;
						break;
					case SemiAxis.YN:
						semiAxis = SemiAxis.ZP;
						break;
					case SemiAxis.ZP:
						semiAxis = SemiAxis.YP;
						break;
					case SemiAxis.ZN:
						semiAxis = SemiAxis.YN;
						break;
				}
				break;
			case Axis.Y:
				switch (getSemiAxis()) {
					case SemiAxis.XP:
						semiAxis = SemiAxis.ZP;
						break;
					case SemiAxis.XN:
						semiAxis = SemiAxis.ZN;
						break;
					case SemiAxis.YP:
						semiAxis = SemiAxis.YP;
						break;
					case SemiAxis.YN:
						semiAxis = SemiAxis.YN;
						break;
					case SemiAxis.ZP:
						semiAxis = SemiAxis.XN;
						break;
					case SemiAxis.ZN:
						semiAxis = SemiAxis.XP;
						break;
				}
				break;
			case Axis.Z:
				switch (getSemiAxis()) {
					case SemiAxis.XP:
						semiAxis = SemiAxis.YN;
						break;
					case SemiAxis.XN:
						semiAxis = SemiAxis.YP;
						break;
					case SemiAxis.YP:
						semiAxis = SemiAxis.XP;
						break;
					case SemiAxis.YN:
						semiAxis = SemiAxis.XN;
						break;
					case SemiAxis.ZP:
						semiAxis = SemiAxis.ZP;
						break;
					case SemiAxis.ZN:
						semiAxis = SemiAxis.ZN;
						break;
				}
				break;
		}
	}
}
